<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JsUnit Assertion Tests</title>
<link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
<script language="JavaScript" type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/lib/imkbizle_jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/sourcesite.js"></script>
<script language="JavaScript" type="text/javascript" src="../content/site_adaptors/akbank.js"></script>
<script language="JavaScript" type="text/javascript">

var responseText = {}

function setUpPage() {
	imkbizle = {
		locale : {
			getString: function(key) {
				var h = {
					"stock.Buy": "Buy",
					"stock.Sell": "Sell"
				};
				return h[key];
			}
		}
	};
	var failureHandler = function() {
		alert("oops! ajax problem!");
	}
	var successHandler = function(key, data) {
		responseText[key] = data;
	};
	akbank.url = "data/akbank.THYAO.html";
	imkbizle_jquery.ajax({
		"url": akbank.url,
		"success": function(data) {successHandler("THYAO", data);},
		"error": failureHandler
	});
	akbank.url = "data/akbank.DOVIZ.html";
	imkbizle_jquery.ajax({
		"url": akbank.url,
		"success": function(data) {successHandler("DOVIZ", data);},
		"error": failureHandler
	});
	setTimeout('setUpPageStatus = "complete"', 2);
}

function testSiteName() {
	assertEquals("wrong site name!", "AKBANK", akbank.sitename);
}

function testSiteUrl() {
	assertEquals("wrong site url!", "data/akbank.DOVIZ.html", akbank.url);
}

function testCreateParams() {
	var param = akbank.createParams("THYAO");
	assertEquals("malfunction on createParams method!", "THYAO", param.hisse);
}

function testGetName() {
	assertEquals("wrong stock name!", "THYAO", akbank.getName(responseText["THYAO"]));
}

function testGetLatest() {
	assertEquals("wrong latest value!", 4.54, akbank.getLatest(responseText["THYAO"]));
}

function testGetOpen() {
	assertEquals("wrong open value!", 4.68, akbank.getOpen(responseText["THYAO"]));
}

function testGetChange() {
	assertEquals("wrong change value!", "%-2.99", akbank.getChange(responseText["THYAO"]));
}

function testGetVol() {
	assertEquals("wrong volume!", 411.471, akbank.getVol(responseText["THYAO"]));
}

function testGetBuy() {
	assertEquals("wrong buy value!", 4.54, akbank.getBuy(responseText["THYAO"]));
}

function testGetSell() {
	assertEquals("wrong sell value!", 4.56, akbank.getSell(responseText["THYAO"]));
}

function testGetUSDTRY() {
	var usdtry = akbank.getExtra("USDTRY", responseText["DOVIZ"]);
	assertEquals("wrong usdtry value!", "1,22700", usdtry.value);
	assertEquals("wrong usdtry tooltip!", "Buy: 1,22700 | Sell: 1,25100", usdtry.tooltip);
}

function testGetEURTRY() {
	var eurtry = akbank.getExtra("EURTRY", responseText["DOVIZ"]);
	assertEquals("wrong usdtry value!", "1,94660", eurtry.value);
	assertEquals("wrong usdtry tooltip!", "Buy: 1,94660 | Sell: 1,98520", eurtry.tooltip);
}

</script>
</head>

<body>
<h1>Akbank Adaptor Tests</h1>

<p>This page contains tests for the akbank adaptor for imkbizle.</p>
</body>
</html>
